package org.lsms.servlet;

/**
 * select topic servlet
 * @author ZhanXueliang
 * 2010.8.20
 */

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.lsms.dao.impl.DaoImpl;

public class select_topic extends HttpServlet {

	public void destroy() {
		super.destroy(); 
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			DaoImpl impl = new DaoImpl(); 
			HttpSession session = request.getSession();
			int userid = Integer.parseInt(session.getAttribute("userid").toString());
			int permission = Integer.parseInt(session.getAttribute("permission").toString());
			String topic1 = request.getParameter("topic1");
			String topic2 = request.getParameter("topic2");
			String topic3 = request.getParameter("topic3");
			String topic4 = request.getParameter("topic4");
			
			if(impl.select_topic(userid, topic1, topic2, topic3, topic4)){
				String info = "Update topic information successfully!";
				switch(permission){
				case 0:
					response.sendRedirect("chair/chair_show_info.jsp?chair_info="+info);
					break;
				case 1:
					response.sendRedirect("member/member_show_info.jsp?member_info="+info);
					break;
				case 2:
					response.sendRedirect("reviewer/reviewer_show_info.jsp?reviewer_info="+info);
					break;
				case 3:
					response.sendRedirect("author/author_show_info.jsp?author_info="+info);
					break;
				case 4:
					response.sendRedirect("admin/admin_show_info.jsp?admin_info="+info);
				}
			}else{
				response.sendRedirect("error/select_topic_failed.jsp");
			}
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			this.doGet(request, response);
	}

	public void init() throws ServletException {
	}

}
